package com.game.globalconst;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JsonUtil {

	public static ObjectMapper om = new ObjectMapper();
	
	public static String parseToString(Object value){
		try {
			return om.writeValueAsString(value);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}
		return null;
	}
	public static <T> T parseToObj(String jsonStr, Class<T> clazz) throws JsonParseException, JsonMappingException, IOException{
		return om.readValue(jsonStr, clazz);
	}
}
